package bz.ziro.kanbe.controller;

import org.slim3.controller.Navigation;

import com.google.appengine.repackaged.com.google.common.base.StringUtil;

import bz.ziro.kanbe.logic.MailLogic;
import bz.ziro.kanbe.model.Page;
import bz.ziro.kanbe.model.Site;

/**
 * メール送信
 * @author Administrator
 */
public class SendMailController extends PostController {

	@Override
	protected void post(Site site, Page page, Navigation redirectNavi) {
		
		String text = "";
		
		String title = requestScope("mailTitle");
		String mail  = requestScope("mailAddress");
		String body  = requestScope("mailBody");
	
		//どれかが空だった場合
		if ( StringUtil.isEmpty(title) || 
			 StringUtil.isEmpty(mail) ||
			 StringUtil.isEmpty(body) ) {
			return;
		}
	
		//メールの内容を作成
		text += "タイトル:" + title + "\n";
		text += "アドレス:" + mail + "\n";
		text += "内容：" +"\n"+ body;

		//コメントメールを送信
		MailLogic.sendMail(text);
		return;
	}
}
